package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.util.Objects;

@Entity
public class Berths {
    private int berthsId;
    private Integer berthsState;
    private Integer berthsCost;
    private String berthsLocation;
    private Wards wardsByWardsId;

    @Id
    @Column(name = "berths_id", nullable = false)
    public int getBerthsId() {
        return berthsId;
    }

    public void setBerthsId(int berthsId) {
        this.berthsId = berthsId;
    }

    @Basic
    @Column(name = "berths_state", nullable = true)
    public Integer getBerthsState() {
        return berthsState;
    }

    public void setBerthsState(Integer berthsState) {
        this.berthsState = berthsState;
    }

    @Basic
    @Column(name = "berths_cost", nullable = true, precision = 0)
    public Integer getBerthsCost() {
        return berthsCost;
    }

    public void setBerthsCost(Integer berthsCost) {
        this.berthsCost = berthsCost;
    }

    @Basic
    @Column(name = "berths_location", nullable = true, length = 50)
    public String getBerthsLocation() {
        return berthsLocation;
    }

    public void setBerthsLocation(String berthsLocation) {
        this.berthsLocation = berthsLocation;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Berths berths = (Berths) o;
        return berthsId == berths.berthsId &&
                Objects.equals(berthsState, berths.berthsState) &&
                Objects.equals(berthsCost, berths.berthsCost) &&
                Objects.equals(berthsLocation, berths.berthsLocation);
    }

    @Override
    public int hashCode() {
        return Objects.hash(berthsId, berthsState, berthsCost, berthsLocation);
    }

    @ManyToOne
    @JoinColumn(name = "wards_id", referencedColumnName = "wards_id")
    public Wards getWardsByWardsId() {
        return wardsByWardsId;
    }

    public void setWardsByWardsId(Wards wardsByWardsId) {
        this.wardsByWardsId = wardsByWardsId;
    }
}
